﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace FuturamaKassa {
    public class Logger {
        private static Logger instance;
        private String logMessage;
        private String logfilePath;
        private StreamWriter writer;

        private Logger() {
            this.logfilePath = "C:\\Users\\Leon\\log.txt";
            if (File.Exists(logfilePath)) {
                File.Delete(logfilePath);
            }
        }

        public static Logger Instance {
            get {
                if (instance == null) {
                    instance = new Logger();
                }
                return instance;
            }
        }

        public void writeLog(String logMessage) {
            this.logMessage = logMessage;
            this.writer = File.AppendText(logfilePath);

            this.writer.WriteLine("{0} {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString());
            this.writer.WriteLine("  :{0}", logMessage);
            this.writer.WriteLine("-------------------------------");

            this.writer.Flush();
            this.writer.Close();

        }
    }
}
